<template>
<div class="log s-singlePage">
  <searchForm ref="searchForm" :keys="['userName']" @on-search="onSearch"></searchForm>
  <div class="table">
    <el-table
        :header-cell-style="{background:'#F8F9FA'}"
        :data="tableData"
        v-loading="loading"
        :height="'calc(100% - 0px)'"
        stripe>
      <el-table-column
          prop=""
          width="80"
          label="">
      </el-table-column>
      <el-table-column
          prop="userName"
          label="登录人">
      </el-table-column>
      <el-table-column
          prop="status"
          label="操作类型">
      </el-table-column><el-table-column
        prop="message"
        label="登录信息">
    </el-table-column>
      <el-table-column
          prop="time"
          label="登陆时间">
      </el-table-column>
      <el-table-column
          prop="ip"
          label="ip地址">
      </el-table-column>
    </el-table>
    <pagination :page="pageInfo.page" :pageSize="pageInfo.pageSize" :total="pageInfo.total" @pageChange="pageChange" @handleSizeChange="pageSizeChange"></pagination>
  </div>
</div>
</template>

<script>
import searchForm from "../../../components/searchForm";
import pagination from "../../../components/pagination";
export default {
  name: "log",
  components:{
    searchForm,
    pagination
  },
  mounted() {
    this.getLoginLog();
  },
  methods:{
    pageSizeChange(size){
      this.pageInfo.pageSize = size;
      this.getLoginLog();
    },
    pageChange(page){
      this.pageInfo.page = page;
      this.getLoginLog();
    },
    getLoginLog(){
      this.loading = true
      let params = {
        userName:this.$refs.searchForm.form.userName,
        page:this.pageInfo.page - 1,
        pageSize:this.pageInfo.pageSize
      }
      this.$api.getLoginLog(params).then(res=>{
        this.tableData = res.data.data
        this.pageInfo.total = res.data.recordsTotal
        this.loading = false
      })
    },
    onSearch(){
      this.pageInfo.page = 1;
      this.getLoginLog();
    },
  },
  data() {
    return {
      tableData: [],
      loading:false,
      pageInfo:{
        page:1,
        pageSize:10,
        total:0
      }
    }
  }
}
</script>

<style scoped lang="less">
.table{
 height:  calc(100% - 130px);
}
.log{
  padding: 15px;
}
</style>